package gui;

import information.Job;

import java.util.Comparator;
import java.util.Vector;

/**
 * This class is supposed to create a comparator that does primary, secondary, and tertiary sorting.
 * It does not do that, and I ran out of time to debug.
 * Supports User story 7
 * This isn't part of the requirements, as user story 7 didn't specify a sort of this type,
 * it was just a "nice to have"
 * @author Christian
 *
 */
public class JobMultiComparator implements Comparator<Job> {
	Vector<Comparator<Job>> myComparators;
	
	public JobMultiComparator() {
		myComparators = new Vector<Comparator<Job>>();
	}
	
	public void addComparator(Comparator<Job> c) {
		myComparators.add(c);
	}
	
	public void removeComparator(Comparator<Job> c) {
		myComparators.remove(c);
	}
	
	/**
	 * Sorts based on the comparators passed in.
	 * This is probably where the logic fails for p,s,t sorting.
	 */
	public int compare (Job j1, Job j2) {
		int result = 0;
		Comparator<Job> c;
		for (int i = 0; i < myComparators.size(); i++) {
			c = myComparators.elementAt(i);
			result = c.compare(j1, j2);
			if (result != 0) {
				break;
			}
		}
		return result;
	}

}
